package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"html/template"
	"net/http"
	"time"
)
func formatAsDate(t time.Time) string {
	year, month, day := t.Date()
	return fmt.Sprintf("%d/%02d/%02d", year, month, day)
}
func main() {
	r:=gin.Default()

	//r.LoadHTMLFiles("template/index.html")
	//r.GET("/", func(context *gin.Context) {
	//		context.HTML(http.StatusOK,"index.html")
	//})
	//r.LoadHTMLGlob("template/**/*")
	//r.GET("/index", func(context *gin.Context) {
	//	context.HTML(http.StatusOK,"index/index.html",gin.H{
	//		"title":"summer",
	//	})
	//})
	//r.GET("/admin", func(context *gin.Context) {
	//	context.HTML(http.StatusOK,"admin/index.html",gin.H{
	//		"title":"summer",
	//	})
	//})
	r.Delims("{[{","}]}")
	r.SetFuncMap(template.FuncMap{
		"formatAsDate": formatAsDate,
	})
	r.LoadHTMLFiles("template/index/new.html")
	r.GET("/delims", func(context *gin.Context) {
		context.HTML(http.StatusOK,"new.html",gin.H{
			"date": time.Date(2017, 07, 01, 0, 0, 0, 0, time.UTC),
		})
	})
	r.Run()
}
